package simpleeditor.model;

import java.util.Hashtable;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import simpleeditor.Strings;

public class Group {

	private String name;
	private int multiplicity;
	private Map<String,Property> properties;

	public Group(){
		this.multiplicity=0;
		this.properties=new Hashtable<String,Property>();
		this.name=Strings.GROUP_DEFAULT_PREFIX+this.hashCode();
	}
	
	public List<Property> getProperties() {
		List<Property> l;
		
		l=new LinkedList<Property>();
		
		for(Entry<String, Property> e:properties.entrySet()){
			l.add(e.getValue());
		}
		
		return l;
	}

	public int getMultiplicity() {
		return multiplicity;
	}

	public void setMultiplicity(int multiplicity) {
		this.multiplicity = multiplicity;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name=name;
	}
	
	public String newProperty(){
		Property p;
		String propId;
		
		p= new Property();
		propId=p.getName();
		
		properties.put(propId, p);
		
		return propId;
	}

	public Property getProperty(String propId) {
		return properties.get(propId);
	}

	public Property removeProperty(String item) {
		return properties.remove(item);
		
	}

}
